//
//  WhsInAddView.m
//  HAODE
//
//  Created by panquanReabam.com on 16/5/30.
//  Copyright © 2016年 reabam.com. All rights reserved.
//

#import "WhsInAddView.h"

#import "GoodsView.h"

@interface WhsInAddView()<UITextViewDelegate,UITextFieldDelegate>
@end

@implementation WhsInAddView
{
    GoodsView*GoodView;
    UILabel * remarkLabel;
    UIImageView*imagess;
    UIView* myToolBar;
    UIView* view;
    UIView*view2;

}
@synthesize mDelegate;


- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
       
        UIView*view1=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 40)];
        view1.backgroundColor=[UIColor whiteColor];
        [self addSubview:view1];
        UILabel *line1=[[UILabel alloc] initWithFrame:CGRectMake(0, 40, ScreenWidth, 0.40)];
        line1.backgroundColor=qianhuiColor;
        [self addSubview:line1];
        UILabel* userName=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, 40, 40)];
        userName.text=[NSString stringWithFormat:@"员工"];
        userName.textColor=shenhuiColor;
        userName.font=[UIFont systemFontOfSize:contenfot];
        [self addSubview:userName];
        
        NSUserDefaults *user1 = [NSUserDefaults standardUserDefaults];
        NSString* UserName = [user1 objectForKey:@"userName"];
        _staffNameBtn=[[UIButton alloc]initWithFrame:CGRectMake(55, 0,ScreenWidth-100,40)];
        [_staffNameBtn setTitle:UserName forState:UIControlStateNormal];
        _staffNameBtn.titleLabel.font=[UIFont systemFontOfSize:contenfot];
        _staffNameBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
        [_staffNameBtn addTarget:self action:@selector(chooseUserBtn:) forControlEvents:UIControlEventTouchUpInside];
        [_staffNameBtn setTitleColor:qianheiColor forState:UIControlStateNormal];
        [self addSubview:_staffNameBtn];
        
        
        UIButton*zhankai = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-40,5,33, 33)];
        [zhankai addTarget:self action:@selector(chooseUserBtn:) forControlEvents:UIControlEventTouchUpInside];
        [zhankai setImage:[UIImage imageNamed:@"zhankai"] forState:UIControlStateNormal];
        [self addSubview:zhankai];

    
    }

    return self;
}
-(void)setModel:(WhsInAddModel *)model{

    view=[[UIView alloc]initWithFrame:CGRectMake(0, 50, ScreenWidth, 200)];
    view.backgroundColor=zuiqianhuiColor;
    [self addSubview:view];
    
    
    
    if ([model.createName isEqualToString:@"NeedOrder"]) {//要货

        view2=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 45)];
        view2.backgroundColor=[UIColor whiteColor];
        view2.layer.borderWidth = 0.40;
        view2.layer.borderColor = qianhuiColor.CGColor;
        [view addSubview:view2];

        UILabel*typeLabel=[[UILabel alloc]initWithFrame:CGRectMake(15,0, 200, 45)];
        typeLabel.text=@"类型";
        typeLabel.textColor=shenhuiColor;
        typeLabel.font=[UIFont systemFontOfSize:contenfot];
        [view2 addSubview:typeLabel];
        _typeBtn=[[UIButton alloc]initWithFrame:CGRectMake(55,  0, ScreenWidth-100,45)];
        _typeBtn.titleLabel.font=[UIFont systemFontOfSize:contenfot];
        _typeBtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentRight;
        [_typeBtn addTarget:self action:@selector(xuanzhidaogou:) forControlEvents:UIControlEventTouchUpInside];
        [_typeBtn setTitleColor:qianheiColor forState:UIControlStateNormal];
        [view2 addSubview:_typeBtn];
        
        UIButton*jiantouBtn = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-40,5,33, 33)];
        [jiantouBtn setImage:[UIImage imageNamed:@"shouqi"] forState:UIControlStateNormal];
        [jiantouBtn addTarget:self action:@selector(xuanzhidaogou:) forControlEvents:UIControlEventTouchUpInside];
        [view2 addSubview:jiantouBtn];

    }else  if ([model.createName isEqualToString:@"CheckVouch"]||[model.createName isEqualToString:@"WhsOut"]||[model.createName isEqualToString:@"WhsIn"]) {//要货{//盘点 入库 出库

       
        view2=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 45*2)];
        view2.backgroundColor=[UIColor whiteColor];
        view2.layer.borderWidth = 0.40;
        view2.layer.borderColor = qianhuiColor.CGColor;
        [view addSubview:view2];
        
        UILabel *line3=[[UILabel alloc] initWithFrame:CGRectMake(10,  45, ScreenWidth-20, 0.40)];
        line3.backgroundColor=qianhuiColor;
        [view2 addSubview:line3];
        
        UILabel*typeLabel=[[UILabel alloc]initWithFrame:CGRectMake(15,0, 200,45)];
        typeLabel.text=@"类型";
        typeLabel.textColor=shenhuiColor;
        typeLabel.font=[UIFont systemFontOfSize:contenfot];
        [view2 addSubview:typeLabel];
        _typeBtn=[[UIButton alloc]initWithFrame:CGRectMake(55,  0, ScreenWidth-100,45)];
        _typeBtn.titleLabel.font=[UIFont systemFontOfSize:contenfot];
        _typeBtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentRight;
        [_typeBtn addTarget:self action:@selector(xuanzhidaogou:) forControlEvents:UIControlEventTouchUpInside];
        [_typeBtn setTitleColor:qianheiColor forState:UIControlStateNormal];
        [view2 addSubview:_typeBtn];
        
        UIButton*jiantouBtn = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-40,5,33, 33)];
        [jiantouBtn setImage:[UIImage imageNamed:@"shouqi"] forState:UIControlStateNormal];
        [jiantouBtn addTarget:self action:@selector(xuanzhidaogou:) forControlEvents:UIControlEventTouchUpInside];
        [view2 addSubview:jiantouBtn];

    
        UILabel*whsLabel=[[UILabel alloc]initWithFrame:CGRectMake(15,45, 200, 45)];
        whsLabel.text=@"仓库";
        whsLabel.textColor=shenhuiColor;
        whsLabel.font=[UIFont systemFontOfSize:contenfot];
        [view2 addSubview:whsLabel];
    
        _whsBtn=[[UIButton alloc]initWithFrame:CGRectMake(55,  45, ScreenWidth-100,45)];
        [_whsBtn setTitle:@"                                                             " forState:UIControlStateNormal];
        _whsBtn.titleLabel.font=[UIFont systemFontOfSize:contenfot];
        _whsBtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentRight;
        [_whsBtn addTarget:self action:@selector(xuanzhidaogou1:) forControlEvents:UIControlEventTouchUpInside];
        [_whsBtn setTitleColor:qianheiColor forState:UIControlStateNormal];
        [view2 addSubview:_whsBtn];
    
        UIButton*jiantouBtn1 = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-40,45+5,33, 33)];
        [jiantouBtn1 setImage:[UIImage imageNamed:@"shouqi"] forState:UIControlStateNormal];
        [jiantouBtn1 addTarget:self action:@selector(xuanzhidaogou1:) forControlEvents:UIControlEventTouchUpInside];
        [view2 addSubview:jiantouBtn1];
    
    
    }else  if ([model.createName isEqualToString:@"Allot"]) {//调拨
        
        
        view2=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 45*3)];
        view2.backgroundColor=[UIColor whiteColor];
        view2.layer.borderWidth = 0.40;
        view2.layer.borderColor = qianhuiColor.CGColor;
        [view addSubview:view2];
        
        UILabel *line3=[[UILabel alloc] initWithFrame:CGRectMake(10,  45, ScreenWidth-20, 0.40)];
        line3.backgroundColor=qianhuiColor;
        [view2 addSubview:line3];
        
        UILabel*typeLabel=[[UILabel alloc]initWithFrame:CGRectMake(15,0, 200, 45)];
        typeLabel.text=@"类型";
        typeLabel.textColor=shenhuiColor;
        typeLabel.font=[UIFont systemFontOfSize:contenfot];
        [view2 addSubview:typeLabel];
        _typeBtn=[[UIButton alloc]initWithFrame:CGRectMake(55,  0, ScreenWidth-100,45)];
        _typeBtn.titleLabel.font=[UIFont systemFontOfSize:contenfot];
        _typeBtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentRight;
        [_typeBtn addTarget:self action:@selector(xuanzhidaogou:) forControlEvents:UIControlEventTouchUpInside];
        [_typeBtn setTitleColor:qianheiColor forState:UIControlStateNormal];
        [view2 addSubview:_typeBtn];
        
        UIButton*jiantouBtn = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-40,5,33, 33)];
        [jiantouBtn setImage:[UIImage imageNamed:@"shouqi"] forState:UIControlStateNormal];
        [jiantouBtn addTarget:self action:@selector(xuanzhidaogou:) forControlEvents:UIControlEventTouchUpInside];
        [view2 addSubview:jiantouBtn];
        
        
        UILabel*whsLabel=[[UILabel alloc]initWithFrame:CGRectMake(15,45, 200, 45)];
        whsLabel.text=@"从仓库";
        whsLabel.textColor=shenhuiColor;
        whsLabel.font=[UIFont systemFontOfSize:contenfot];
        [view2 addSubview:whsLabel];
        
        _whsBtn=[[UIButton alloc]initWithFrame:CGRectMake(55,  45, ScreenWidth-100,45)];
        [_whsBtn setTitle:@"                                                             " forState:UIControlStateNormal];
        _whsBtn.titleLabel.font=[UIFont systemFontOfSize:contenfot];
        _whsBtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentRight;
        [_whsBtn addTarget:self action:@selector(AllotWhs:) forControlEvents:UIControlEventTouchUpInside];
        [_whsBtn setTitleColor:qianheiColor forState:UIControlStateNormal];
        [view2 addSubview:_whsBtn];
        
        UIButton*jiantouBtn1 = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-40,45+5,33, 33)];
        [jiantouBtn1 setImage:[UIImage imageNamed:@"shouqi"] forState:UIControlStateNormal];
        [jiantouBtn1 addTarget:self action:@selector(AllotWhs:) forControlEvents:UIControlEventTouchUpInside];
        [view2 addSubview:jiantouBtn1];
        
        UILabel*whsLabel1=[[UILabel alloc]initWithFrame:CGRectMake(15,90, 200, 45)];
        whsLabel1.text=@"到仓库";
        whsLabel1.textColor=shenhuiColor;
        whsLabel1.font=[UIFont systemFontOfSize:contenfot];
        [view2 addSubview:whsLabel1];
        UILabel *line4=[[UILabel alloc] initWithFrame:CGRectMake(10,  90, ScreenWidth-20, 0.40)];
        line4.backgroundColor=qianhuiColor;
        [view2 addSubview:line4];
        
        _whsBtn1=[[UIButton alloc]initWithFrame:CGRectMake(55,  90, ScreenWidth-100,45)];
        [_whsBtn1 setTitle:@"                                                             " forState:UIControlStateNormal];
        _whsBtn1.titleLabel.font=[UIFont systemFontOfSize:contenfot];
        _whsBtn1.contentHorizontalAlignment=UIControlContentHorizontalAlignmentRight;
        [_whsBtn1 addTarget:self action:@selector(AllotWhs1:) forControlEvents:UIControlEventTouchUpInside];
        [_whsBtn1 setTitleColor:qianheiColor forState:UIControlStateNormal];
        [view2 addSubview:_whsBtn1];
        
        UIButton*jiantouBtn11 = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-40,90+5,33, 33)];
        [jiantouBtn11 setImage:[UIImage imageNamed:@"shouqi"] forState:UIControlStateNormal];
        [jiantouBtn11 addTarget:self action:@selector(AllotWhs1:) forControlEvents:UIControlEventTouchUpInside];
        [view2 addSubview:jiantouBtn11];

   
    }else  if ([model.createName isEqualToString:@"Refund"]) {//退货
        
        
        view2=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 45+50+10)];
        view2.backgroundColor=[UIColor whiteColor];
        view2.layer.borderWidth = 0.40;
        view2.layer.borderColor = qianhuiColor.CGColor;
        [view addSubview:view2];
        UIView*gayView=[[UIView alloc]initWithFrame:CGRectMake(0, 45, ScreenWidth, 10)];
        gayView.backgroundColor=zuiqianhuiColor;
        gayView.layer.borderWidth = 0.40;
        gayView.layer.borderColor = qianhuiColor.CGColor;
        [view2 addSubview:gayView];

        
        UILabel*typeLabel=[[UILabel alloc]initWithFrame:CGRectMake(15,0, 200, 45)];
        typeLabel.text=@"类型";
        typeLabel.textColor=shenhuiColor;
        typeLabel.font=[UIFont systemFontOfSize:contenfot];
        [view2 addSubview:typeLabel];
        _typeBtn=[[UIButton alloc]initWithFrame:CGRectMake(55,  0, ScreenWidth-100,45)];
        _typeBtn.titleLabel.font=[UIFont systemFontOfSize:contenfot];
        _typeBtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentRight;
        [_typeBtn addTarget:self action:@selector(xuanzhidaogou:) forControlEvents:UIControlEventTouchUpInside];
        [_typeBtn setTitle:_RefundTypeName forState:UIControlStateNormal];
        [_typeBtn setTitleColor:qianheiColor forState:UIControlStateNormal];
        [view2 addSubview:_typeBtn];
        
        UIButton*jiantouBtn = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-40,5,33, 33)];
        [jiantouBtn setImage:[UIImage imageNamed:@"shouqi"] forState:UIControlStateNormal];
        [jiantouBtn addTarget:self action:@selector(xuanzhidaogou:) forControlEvents:UIControlEventTouchUpInside];
        [view2 addSubview:jiantouBtn];
        
        
        UIView*memberView=[[UIView alloc]initWithFrame:CGRectMake(0, 55, ScreenWidth,  50)];
        memberView.backgroundColor=[UIColor whiteColor];
        [view2 addSubview:memberView];
        
        UIView*gayView1=[[UIView alloc]initWithFrame:CGRectMake(0, memberView.bottom, ScreenWidth, 10)];
        gayView1.backgroundColor=zuiqianhuiColor;
        gayView1.layer.borderWidth = 0.40;
        gayView1.layer.borderColor = qianhuiColor.CGColor;
        [view2 addSubview:gayView1];
        
        
        NSString *s = [NSString stringWithFormat:@"%@(%@)",   self.userName, self.phone];
        UIFont *font = [UIFont systemFontOfSize:15];
        CGSize size = CGSizeMake(320, 2000);
        CGSize labelsize = [s sizeWithFont:font constrainedToSize:size lineBreakMode:NSLineBreakByCharWrapping];
        
        UILabel*memberLabel=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, labelsize.width+3, 50)];
         memberLabel.font=[UIFont systemFontOfSize:15];
        if ([self.userName length]==0){
            memberLabel.text=@"会员信息...";
            memberLabel.textColor=zhonghuiColor;
            [memberLabel setFrame:CGRectMake(15, 0, ScreenWidth-30, 50)];
        }else{
            memberLabel.text=[NSString stringWithFormat:@"%@(%@)",   self.userName, self.phone];
            UIImageView*Seximage=[[UIImageView alloc]initWithFrame:CGRectMake(memberLabel.right+5, 14.5, 20, 20)];
            if (![self.sex isEqual:[NSNull null]]) {
                
                if ([self.sex isEqualToString:@"男"]) {
                    
                    
                    Seximage.image=[UIImage imageNamed:@"nan"];
                    
                }else{
                    
                    Seximage.image=[UIImage imageNamed:@"nv"];
                    
                }
                [memberView addSubview:Seximage];
            }

            
            NSString *s1 = [NSString stringWithFormat:@"%@",   self.gradeName];
            UIFont *font1 = [UIFont systemFontOfSize:14];
            CGSize size1 = CGSizeMake(320, 2000);
            CGSize labelsize1 = [s1 sizeWithFont:font1 constrainedToSize:size1 lineBreakMode:NSLineBreakByCharWrapping];
            UILabel*grade=[[UILabel alloc] initWithFrame:CGRectMake(Seximage.right+5,17.5,labelsize1.width, 14)];
            grade.text=self.gradeName;
            grade.textColor=[UIColor whiteColor];
            grade.textAlignment=NSTextAlignmentCenter;
            grade.font=[UIFont systemFontOfSize:13];
            grade.backgroundColor=[UIColor colorWithRed:209/255.0 green:170/255.0 blue:56/255.0 alpha:1.0];
            [memberView addSubview:grade];
            
        }
        [memberView addSubview:memberLabel];
        
        UILabel *l=[[UILabel alloc] initWithFrame:CGRectMake(ScreenWidth-80,7.5,0.40, 35)];
        l.backgroundColor=qianhuiColor;
        [memberView addSubview:l];
        
        UIButton*sxBtn = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-80+12.5, 50/2-12.5, 50,25)];
            if ([self.userName length]==0){
                [sxBtn setTitle:@"选择" forState:UIControlStateNormal];
            }else{
             [sxBtn setTitle:@"修改" forState:UIControlStateNormal];
            }
        
        [sxBtn.layer setCornerRadius:2];
        [sxBtn.layer setBorderWidth:0.5];
        [sxBtn.layer setMasksToBounds:YES];
        sxBtn.layer.borderColor=[[UIColor colorWithRed:204/255.0 green:204/255.0 blue:204/255.0 alpha:1] CGColor];
        [sxBtn setTitleColor:shenhuiColor  forState:UIControlStateNormal];
        sxBtn.titleLabel.font=[UIFont systemFontOfSize:14];
        [sxBtn addTarget:self action:@selector(chooseBtn:) forControlEvents:UIControlEventTouchUpInside];
        [memberView addSubview:sxBtn];
        
        
    }

    view.frame=CGRectMake(0, 50, ScreenWidth, view2.bottom);
    
  
    UIView*gayView1=[[UIView alloc]initWithFrame:CGRectMake(0, view.bottom, ScreenWidth, 10)];
    gayView1.backgroundColor=zuiqianhuiColor;
    [self addSubview:gayView1];

    
    UIView*view3=[[UIView alloc]initWithFrame:CGRectMake(0, view.bottom+ 10, ScreenWidth, 45)];
    view3.backgroundColor=[UIColor whiteColor];
    [self addSubview:view3];
    UILabel *lineL=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 0.40)];
    lineL.backgroundColor=qianhuiColor;
    [view3 addSubview:lineL];
    
    UILabel*GoodsLabel=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, 80, 45)];
    GoodsLabel.text=@"商品信息";
    GoodsLabel.textColor=qianheiColor;
    GoodsLabel.font=[UIFont systemFontOfSize:15];
    [view3 addSubview:GoodsLabel];
    UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(10, 45-0.40, ScreenWidth-20, 0.40)];
    lineLabel1.backgroundColor=qianhuiColor;
    [view3 addSubview:lineLabel1];
    
    
        _heightView=[[UIView alloc]init];
        _heightView.backgroundColor=qianhuiColor;
        [self addSubview:_heightView];
        _heightView.frame=CGRectMake(0, view3.bottom, ScreenWidth, 0.15);


}

-(void)chooseUserBtn:(UIButton *)sender{
    
    [self.mDelegate chooseUser:@""];
    
}

-(void)chooseBtn:(UIButton *)sender{

    if ([self.mDelegate respondsToSelector:@selector(chooesBtn)]) {
        [self.mDelegate chooesBtn];
    }
}
-(void)xuanzhidaogou:(UIButton *)sender{
 [mDelegate type:@""];
}
-(void)xuanzhidaogou1:(UIButton *)sender{
 [mDelegate whs:@""];
}
-(void)AllotWhs:(UIButton *)sender{
    [mDelegate AllotWhs:@""];
    
}
-(void)AllotWhs1:(UIButton *)sender{
    [mDelegate AllotWhs1:@""];
}


-(void)store{
    
  
    
}
-(void)certificationBtn:(UIButton*)sender{
    
  
}
@end
